<?php
require_once(OC::$SERVERROOT . "/apps/jobposition/lib/folder.php");

$LoginStats = PUtil::checkUserLogin(true);
if ($LoginStats !== true) {
   echo $LoginStats;
   exit();
}

OCP\JSON::callCheck();

$model = new PJobpositionModelFolder();
$fid = $model->saveFolder();

if(!$fid) {
   OC_JSON::error(array('data' => array( 'message' => $model->getError() ? $model->getError() : '系统错误')));
   return false;
}

if(!$model->saveInFolder($fid)) {
   OC_JSON::error(array('data' => array( 'message' => $model->getError() ? $model->getError() : '系统错误')));
   return false;
}

/*
$recordlast = JRequest::getInt('recordlast', 0);
if($recordlast) {
   JRequest::setVar('fid', 0);
   JRequest::setVar('fname', '上次自定义组合');
   JRequest::setVar('system', 1);
   $rlid = $model->saveFolder();
   if(!$rlid) {
      OC_JSON::error(array('data' => array( 'message' => $model->getError() ? $model->getError() : '系统错误')));
      return false;
   }

   if(!$model->saveInFolder($rlid)) {
      OC_JSON::error(array('data' => array( 'message' => $model->getError() ? $model->getError() : '系统错误')));
      return false;
   }
}
*/

OCP\JSON::success(array('data' => $fid));